package com.foreknow.demo0928;

public class Sub extends Base {
    int x = 2;

    @Override
    public void func() {
        System.out.println("Sub");
    }

    public static void main(String[] args) {
        Sub sub = new Sub();
        System.out.println(sub.x);
        sub.func();
        System.out.println("-----------");
        //父类的引用指向子类的对象
        Base base = new Sub();
        System.out.println(base.x);
        base.func();
    }
}
